Q and A - II
Example:
Normalization is the process of organizing data to reduce redundancy and improve data integrity. Advantages:
Example
A transaction is a logical unit of work in a database that must be either fully completed or fully rolled back. ACID:
A deadlock occurs when two or more transactions wait for each other indefinitely to release locks. Prevention methods:
| Feature | OLTP | OLAP |
|---|---|---|
| Purpose | Day-to-day operations | Analytical processing |
| Data | Current, detailed | Historical, summarized |
| Queries | Simple, short | Complex, aggregate |
| Example | Banking, e-commerce | Data warehouse, BI tools |
A view is a virtual table based on a SQL query. Updatable View: Possible if:
A trigger is a stored procedure that automatically executes in response to certain events (INSERT, UPDATE, DELETE). Example:
| CREATE TRIGGER trg_audit | AFTER DELETE ON employees |
| FOR EACH ROW |
| INSERT INTO audit_log(emp_id, deleted_at) VALUES(OLD.emp_id, NOW()); |
A stored procedure is a precompiled SQL block stored in the database. Advantages:
It's the process by which the database engine chooses the most efficient way to execute a query using execution plans, indexes, and statistics. Techniques: